package com.example.cloudecg;

import android.util.Log;

import java.util.Calendar;
import java.util.TimeZone;

public class TimeTools {

    /*



     * 使用Calendar获取系统时间



     */



  private static   Calendar calendars;



    public static void getTime4() {



            calendars = Calendar.getInstance();



        calendars.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));





        int year = calendars.get(Calendar.YEAR);



        String month = String.valueOf(calendars.get(Calendar.MONTH)+1);



        String day = String.valueOf(calendars.get(Calendar.DATE));



        String hour = String.valueOf(calendars.get(Calendar.HOUR));



        String min = String.valueOf(calendars.get(Calendar.MINUTE));



        String second = String.valueOf(calendars.get(Calendar.SECOND));



        Boolean isAm = calendars.get(Calendar.AM_PM)==1 ? true:false;


        String hex = Integer.toHexString((year-2000));
        long lvar = 3243143432134L;
        String lhex = Long.toHexString(lvar);

//        Boolean is24 = DateFormat.is24HourFormat(getApplication()) ?true:false;





        Log.i("md", hex+" 年："+year+" 月： "+month+" 日："+day+" 时： "+hour+" 分： "+min+" 秒： "+second +" 是上午吗？ "+isAm+" 是24小时制吗？ ");



    }


    public static String  IntoTime(){

        int year = calendars.get(Calendar.YEAR);
        String hex = Integer.toHexString((2020-2000));//年
        int month = calendars.get((Calendar.MONTH)+1);//月
        String months = Integer.toHexString(month);
        int day = calendars.get(Calendar.DATE);//日
        String days = Integer.toHexString(day);
        int hour = calendars.get(Calendar.HOUR);//时
        String hours = Integer.toHexString(hour);
        int min = calendars.get(Calendar.MINUTE);//分
        String mins = Integer.toHexString(min);
        int  second = calendars.get(Calendar.SECOND);//秒
        String seconds = Integer.toHexString(second);
        if(months.length()==1){
            months="0"+months;
        }
        if(days.length()==1){
            days="0"+days;
        }
        if(hours.length()==1){
            hours="0"+hours;
        }
        if(mins.length()==1){
            mins="0"+mins;
        }
        if(seconds.length()==1){
            seconds="0"+seconds;
        }
        return "E823"+hex+""+months+""+days+""+hours+""+mins+""+seconds+"07D0";
    }

    public static String  IntoTime_loading(){
        int year = calendars.get(Calendar.YEAR);
        String hex = Integer.toHexString((year-2000));//年
        int month = calendars.get((Calendar.MONTH)+1);//月
        String months = Integer.toHexString(month);
        int day = calendars.get(Calendar.DATE);//日
        String days = Integer.toHexString(day);
        int hour = calendars.get(Calendar.HOUR);//时
        String hours = Integer.toHexString(hour);
        int min = calendars.get(Calendar.MINUTE);//分
        String mins = Integer.toHexString(min);
        int  second = calendars.get(Calendar.SECOND);//秒
        String seconds = Integer.toHexString(second);
        if(months.length()==1){
            months="0"+months;
        }
        if(days.length()==1){
            days="0"+days;
        }
        if(hours.length()==1){
            hours="0"+hours;
        }
        if(mins.length()==1){
            mins="0"+mins;
        }
        if(seconds.length()==1){
            seconds="0"+seconds;
        }
        return "e840"+hex+""+months+""+days+""+hours+""+mins+""+seconds;
    }


}
